package com.tutu.book.mapper;


import com.tutu.commons.entity.Book;

import feign.Param;
import org.apache.ibatis.annotations.Mapper;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @Program: SpringCloud
 * @Description:
 * @Author: JK.TuTu
 * @ @Version: 1.0
 * @Create: 2022-12-01 13:04
 **/
@Mapper
public interface BookMapper {

    @Select("select * from db_book where bid = #{bid}")
    Book getBookById(int bid);

    /**
     * 根据bid获取当前图书数量
     */
    @Select("select count from db_book where bid=#{bid}")
    int getBookNum(@Param("bid") int bid);

    /**
     * 实现图书借阅
     */
    @Update("update db_book set count=#{num} where bid=#{bid}")
    int bookBorrow(@Param("bid") int bid, @Param("num") int num);
}